<template>
    <view>
        <!-- #ifdef H5 -->
        <u-navbar title="订单管理" :is-back="false"></u-navbar>
        <!-- #endif -->
        <view class="tabs u-flex-center u-row-between">
            <!-- <view style="width:75%;">
				<u-tabs ref="tabs" :current="current" :list="tabList" bar-height="6" bar-width="50" active-color="#606DCE" font-size="28" inactive-color="#888888" :is-scroll="false" @change="change"></u-tabs>
			</view>	 -->
            <view class="flex-one tabsbg">
                <view
                    class="flex flex-column align-center margin-right-30"
                    v-for="(item, index) in tabList"
                    :key="index"
                    @click="change(index)"
                >
                    <view
                        class="text-28"
                        :style="current == index ? 'color:#606DCE' : ''"
                        >{{ item.name }}</view
                    >
                    <view class="tabline" v-if="current == index"></view>
                </view>
            </view>
            <image
                src="@/static/yCreate/screen.png"
                mode="widthFix"
                class="screen"
                @click="show_screen = true"
            ></image>
        </view>
        <mescroll-body
            :sticky="true"
            ref="mescrollRef"
            @init="mescrollInit"
            @down="downCallback"
            @up="upCallback"
        >
            <view class="all">
                <view
                    class="card"
                    v-for="(item, index) in flowList"
                    :key="index"
                >
                    <!-- <view class="shop-message u-flex">
						<image src="@/static/yCreate/shopIcon.png" mode="widthFix"></image>
						<view>{{item.ordergoods.title}}</view>
					</view> -->
                    <view
                        class="top u-flex-center u-row-between"
                        v-if="current <= 3"
                    >
                        <view>订单号：{{ item.order_no }}</view>
                        <view
                            class="state"
                            style="color: #ff0000"
                            v-if="item.state == 1"
                            >待支付</view
                        >
                        <view class="state" v-if="item.state == 2">待发货</view>
                        <view
                            class="state"
                            style="color: #ff0000"
                            v-if="item.state == 3"
                            >待收货</view
                        >
                        <view class="state" v-if="item.state == 7">已取消</view>
                        <view
                            class="state"
                            style="color: #606dce"
                            v-if="item.state == 4 || item.state == 6"
                            >已完成</view
                        >
                    </view>
                    <view
                        class="top u-flex-center u-row-between"
                        v-if="current > 3"
                    >
                        <view>订单号：{{ item.order.order_no }}</view>
                        <view
                            class="state"
                            style="color: #606dce"
                            v-if="item.state == 0"
                            >申请退款</view
                        >
                        <view
                            class="state"
                            style="color: #606dce"
                            v-if="item.state == 1 && item.type != 1"
                            >卖家同意</view
                        >
                        <view
                            class="state"
                            style="color: #606dce"
                            v-if="item.state == 2"
                            >卖家拒绝</view
                        >
                        <view
                            class="state"
                            style="color: #606dce"
                            v-if="item.state == 3"
                            >申请平台介入</view
                        >
                        <view
                            class="state"
                            style="color: #606dce"
                            v-if="item.state == 4"
                            >成功退款</view
                        >
                        <view
                            class="state"
                            style="color: #606dce"
                            v-if="item.state == 5"
                            >退款已关闭</view
                        >
                        <view
                            class="state"
                            style="color: #606dce"
                            v-if="item.state == 6"
                            >已提交物流</view
                        >
                        <view
                            class="state"
                            style="color: #606dce"
                            v-if="item.state == 1 && item.type == 1"
                            >待卖家退回</view
                        >
                        <view
                            class="state"
                            style="color: #606dce"
                            v-if="item.state == 7"
                            >第三方退款中</view
                        >
                        <view
                            class="state"
                            style="color: #606dce"
                            v-if="item.state == 8"
                            >退款失败</view
                        >
                    </view>
                    <view
                        class="u-flex-center u-row-left u-m-t-20"
                        v-for="(_item, _index) in item.ordergoods"
                        v-if="current <= 3"
                        @click="goDetail(item.id)"
                    >
                        <image
                            :src="_item.image"
                            mode="aspectFill"
                            class="head-img"
                        ></image>
                        <view class="cont">
                            <view class="u-flex u-row-between u-m-t-30">
                                <view class="" style="padding-right: 20rpx;box-sizing: border-box;">
                                    <!-- <text>￥</text>{{ _item.price }} -->
                                    <view class="name u-line-2" style="line-height: 1.2rem">{{
                                        _item.title
                                    }}</view>
                                </view>
                                <view class="number"
                                    >×{{ item.ordergoods[0].number }}</view
                                >
                            </view>
                        </view>
                    </view>
                    <view
                        class="u-flex-center u-row-left u-m-t-20"
                        v-if="current > 3"
                        @click="goDetail(item.id)"
                    >
                        <image
                            :src="item.goods.image"
                            mode="aspectFill"
                            class="head-img"
                        ></image>
                        <view class="cont">
                            <view class="name u-line-2">{{
                                item.goods.title
                            }}</view>
                            <view class="u-flex u-row-between u-m-t-30">
                                <view class="price"
                                    ><text>￥</text>{{ item.price }}</view
                                >
                                <view class="number"
                                    >×{{ item.ordergoods[0].number }}</view
                                >
                            </view>
                        </view>
                    </view>
                    <!-- v-if="current==2" -->
                    <view class="" v-if="current < 4">
                        <view
                            class="u-flex-center u-row-between u-p-t-30 u-m-t-30 u-border-top"
                            v-if="item.state == 3 || item.state == 2"
                        >
                            <view class="time" v-if="item.state == 3"
                                >等待客户确认收货，30天后自动收货</view
                            >
                            <view class="time" v-if="item.state == 2"
                                >请于3天内发货</view
                            >
                            <view class="time" v-if="is_self == 1"
                                >供货商{{ item.ghshop.shopname }}</view
                            >
                            <view></view>
                            <view class="u-flex-center" v-if="item.state == 2">
                                <!-- <view class="button button1" @click="cancel(item.id)">取消订单</view> -->
                                <!-- <view class="button" @click="showPop(item.id)" v-if="is_self != 1">确认发货</view> -->
                                <view
                                    class="button"
                                    @click="showPop(item.id)"
                                    v-if="hzshop_switch == 1"
                                    >确认发货</view
                                >
                                <view
                                    class="button"
                                    @click="
                                        showGong(
                                            item.id,
                                            item.ordergoods[0].goods_id
                                        )
                                    "
                                    v-if="is_self == 1"
                                    >选择供货商家</view
                                >
                                <!-- <view class="button" @click="confirm(item.id)">确认收货</view> -->
                            </view>
                        </view>
                    </view>
                    <view class="" v-if="current > 3">
                        <view
                            class="u-flex-center u-row-between u-p-t-30 u-m-t-30 u-border-top"
                            v-if="item.state == 0"
                        >
                            <view></view>
                            <view class="u-flex-center" v-if="item.state == 0">
                                <view
                                    class="button button1"
                                    @click="refuse(item.id)"
                                    >拒绝退款</view
                                >
                                <view class="button" @click="agree(item.id)"
                                    >同意退款</view
                                >
                            </view>
                            <view
                                class="u-flex-center"
                                v-if="item.type == 1 && item.state == 6"
                            >
                                <view class="button" @click="rece(item.id)"
                                    >确认收货</view
                                >
                            </view>
                        </view>
                    </view>
                </view>
            </view>
        </mescroll-body>
        <u-popup v-model="show_screen" mode="top" border-radius="20">
            <view class="pop">
                <view class="u-p-30">
                    <u-search
                        placeholder="请输入订单号"
                        v-model="keyword"
                        bg-color="#F6F6F6"
                        :show-action="false"
                        @search="search"
                    ></u-search>
                    <view class="u-flex u-p-t-30">
                        <view
                            class="box-item u-flex-center u-m-r-20"
                            @click="show1 = true"
                        >
                            <text>{{
                                this.tabList[this.current].name || "订单状态"
                            }}</text>
                            <image
                                src="@/static/yCreate/bot.png"
                                mode="widthFix"
                            ></image>
                        </view>
                        <view
                            class="box-item u-flex-center"
                            @click="show2 = true"
                        >
                            <text>{{
                                this.take
                                    ? this.list2[this.take - 1].label
                                    : "成交时间"
                            }}</text>
                            <image
                                src="@/static/yCreate/bot.png"
                                mode="widthFix"
                            ></image>
                        </view>
                    </view>
                    <view class="options-item u-border-bottom">
                        <view class="title">创建时间</view>
                        <view class="u-flex u-flex-wrap">
                            <view
                                class="options-box u-flex-center"
                                v-for="(item, index) in timeList"
                                :class="{ 'select-box': timeIdx == index }"
                                @click="checkIdx(index, 1)"
                            >
                                {{ item }}
                            </view>
                        </view>
                    </view>
                    <view class="options-item u-border-bottom">
                        <view class="title">付款时间</view>
                        <view class="u-flex u-flex-wrap">
                            <view
                                class="options-box u-flex-center"
                                v-for="(item, index) in timeList"
                                :class="{ 'select-box': paymentIdx == index }"
                                @click="checkIdx(index, 2)"
                            >
                                {{ item }}
                            </view>
                        </view>
                    </view>
                </view>
                <view class="u-flex">
                    <view class="btn u-flex-center" @click="show_screen = false"
                        >取消</view
                    >
                    <view class="btn btn2 u-flex-center" @click="getlist()"
                        >确定</view
                    >
                </view>
            </view>
        </u-popup>
        <u-popup v-model="show3" mode="center" border-radius="20">
            <view class="card2">
                <view
                    class="u-flex"
                    style="padding: 20rpx 0; justify-content: space-around"
                >
                    <view
                        class="pop-tit"
                        :style="{ color: boxType == 1 ? '' : '#999' }"
                        @click="boxType = 1"
                    >
                        物流信息
                        <view
                            :class="
                                boxType == 1 ? 'borderBottomLine' : 'bottomLine'
                            "
                        >
                        </view>
                    </view>
                    <view
                        class="pop-tit"
                        :style="{ color: boxType == 2 ? '' : '#999' }"
                        @click="boxType = 2"
                    >
                        千创专线
                        <view
                            :class="
                                boxType == 2 ? 'borderBottomLine' : 'bottomLine'
                            "
                        >
                        </view>
                    </view>
                </view>
                <view v-if="boxType == 1">
                    <view
                        class="item u-border-bottom u-flex-center u-row-between"
                        @click="show4 = true"
                    >
                        <text>快递公司</text>
                        <text class="right" v-if="!corporation">{{
                            "请选择"
                        }}</text>
                        <text class="right right2" v-else>{{
                            corporation
                        }}</text>
                    </view>
                    <view
                        class="item u-border-bottom u-flex-center u-row-between"
                    >
                        <text>快递单号</text>
                        <input
                            type="text"
                            placeholder="请输入快递单号"
                            placeholder-class="ipt-sty"
                            v-model="orderNum"
                        />
                    </view>
                    <input
                        type="text"
                        v-model="remark"
                        placeholder="请输入备注"
                        class="item u-border-bottom u-flex-center u-row-between"
                    />
                    <view class="flex pop-button u-row-between">
                        <view
                            class="u-flex-center"
                            style="font-size: 30rpx"
                            @click="show3 = false"
                            >取消</view
                        >
                        <view
                            class="u-flex-center b2"
                            style="font-size: 30rpx"
                            @click="confirm()"
                            >确定</view
                        >
                    </view>
                </view>
                <view
                    v-if="boxType == 2 && hzshop_switch == 1"
                    style="font-size: 30rpx"
                >
                    <view class="">
                        <view
                            v-for="(item, index) in items"
                            :key="index"
                            class="item u-border-bottom u-flex u-row-between"
                        >
                            <view>{{ item.name }}</view>
                            <view
                                class="box right"
                                @click="choose(item)"
                                style="
                                    border: 1px solid #333;
                                    border-radius: 50%;
                                    width: 40rpx;
                                    height: 40rpx;
                                "
                            >
                                <view class="inner" v-if="index == chooseIndex">
                                    <image
                                        style="width: 100%; height: 100%"
                                        src="/static/wImg/radius.png"
                                        mode="scaleToFill"
                                    />
                                </view>
                            </view>
                        </view>
                    </view>
                    <view
                        class="item u-flex-center u-border-bottom u-row-between"
                    >
                        <text>选择时间</text>
                        <text class="right" @click="clickDate">{{
                            date || "请选择"
                        }}</text>
                        <u-calendar
                            z-index="99999999"
                            v-model="show_date"
                            :min-date="minDate"
                            :max-date="maxDate"
                            mode="date"
                            @change="changeDate"
                        ></u-calendar>
                    </view>
                    <view class="flex pop-button u-row-between">
                        <view
                            class="u-flex-center"
                            style="font-size: 30rpx"
                            @click="show3 = false"
                            >取消</view
                        >
                        <view
                            class="u-flex-center b2"
                            style="font-size: 30rpx"
                            @click="confirm()"
                            >确定</view
                        >
                    </view>
                </view>
            </view>
        </u-popup>
        <!-- 拒绝弹窗 -->
        <u-popup v-model="show5" mode="center" border-radius="20">
            <view class="card2">
                <view class="pop-tit">拒绝原因</view>
                <input
                    type="text"
                    v-model="refuse_content"
                    placeholder="请输入拒绝原因"
                    class="item u-border-bottom u-flex-center u-row-between"
                />
                <view class="flex pop-button u-row-between">
                    <view class="u-flex-center" @click="show5 = false"
                        >取消</view
                    >
                    <view class="u-flex-center b2" @click="getTui()">确定</view>
                </view>
            </view>
        </u-popup>
        <!-- 选择供货商 -->
        <u-popup v-model="show6" mode="center" border-radius="20">
            <view class="card2">
                <view class="pop-tit">选择供货商家</view>
                <view
                    class="item u-border-bottom u-flex-center u-row-between"
                    @click="showstore = true"
                >
                    <text>供货商家</text>
                    <text class="right right2">{{
                        shopname ? shopname : "请选择"
                    }}</text>
                </view>

                <input
                    type="text"
                    v-model="remark"
                    placeholder="请输入备注"
                    class="item u-border-bottom u-flex-center u-row-between"
                />
                <view class="flex pop-button u-row-between">
                    <view class="u-flex-center" @click="show6 = false"
                        >取消</view
                    >
                    <view class="u-flex-center b2" @click="confirmStore()"
                        >确定</view
                    >
                </view>
            </view>
        </u-popup>
        <u-select
            v-model="show1"
            :list="tabList"
            @confirm="confirm1($event, 1)"
            label-name="name"
            confirm-color="#606DCE"
        ></u-select>
        <u-select
            v-model="show2"
            :list="list2"
            @confirm="confirm1($event, 2)"
            confirm-color="#606DCE"
        ></u-select>
        <u-select
            v-model="show4"
            :list="list3"
            label-name="name"
            value-name="code"
            @confirm="confirm1($event, 3)"
            confirm-color="#606DCE"
        ></u-select>
        <u-select
            v-model="showstore"
            :list="store"
            label-name="shopname"
            value-name="id"
            @confirm="confirm1($event, 4)"
            confirm-color="#606DCE"
        ></u-select>
        <u-tabbar
            v-model="currentTab"
            @change="changeTab"
            height="55px"
            active-color="#606DCE"
            inactive-color="#888"
            :list="tabsList"
        ></u-tabbar>
    </view>
</template>

<script>
import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
export default {
    mixins: [MescrollMixin], // 使用mixin
    data() {
        return {
            show1: false,
            show2: false,
            show3: false,
            show4: false,
            show5: false, //拒绝退款弹窗
            show6: false, //选择供货商家
            showstore: false,
            list2: [
                {
                    value: 1,
                    label: "3天之内",
                },
                {
                    value: 2,
                    label: "3-7天",
                },
                {
                    value: 3,
                    label: "7-30天",
                },
                {
                    value: 4,
                    label: "30天以上",
                },
            ],
            list3: [],
            orderNum: "",
            corporation: "",
            tabList: [
                {
                    name: "待支付",
                    value: 1,
                },
                {
                    name: "待发货",
                    value: 2,
                },
                {
                    name: "待收货",
                    value: 3,
                },
                {
                    name: "已取消",
                    value: 4,
                },
                {
                    name: "全部退款",
                    value: 5,
                },
                {
                    name: "待处理",
                    value: 6,
                },
                {
                    name: "已通过",
                    value: 7,
                },
                {
                    name: "已驳回",
                    value: 8,
                },
            ],
            timeIdx: 0,
            paymentIdx: 0,
            take: "", //成交时间
            timeList: ["3天之内", "3-7天", "7-30天", "30天以上"],
            show_screen: false,
            keyword: "",
            flowList: [],
            current: 0,
            id: "",
            code: "",
            tabsList: [
                {
                    iconPath: "https://apishop.qiancdj.com/static/img/home.png",
                    selectedIconPath:
                        "https://apishop.qiancdj.com/img/tabber/home.png",
                    text: "商品",
                },
                {
                    iconPath:
                        "https://apishop.qiancdj.com/static/img/order.png",
                    selectedIconPath:
                        "https://apishop.qiancdj.com/img/tabber/category.png",
                    text: "订单",
                },
                {
                    iconPath: "https://apishop.qiancdj.com/static/img/shen.png",
                    selectedIconPath:
                        "https://apishop.qiancdj.com/img/tabber/sh.png",
                    text: "审核",
                },
                {
                    iconPath: "https://apishop.qiancdj.com/static/img/cart.png",
                    selectedIconPath:
                        "https://apishop.qiancdj.com/img/tabber/card.png",
                    text: "运费",
                },
                {
                    iconPath: "https://apishop.qiancdj.com/static/img/mine.png",
                    selectedIconPath:
                        "https://apishop.qiancdj.com/img/tabber/user.png",
                    text: "我的",
                },
            ],
            items: [
                {
                    name: "千创专线今日达",
                    value: "0",
                },
                {
                    name: "千创专线次日达",
                    value: "1",
                },
            ],
            chooseIndex: 0,
            currentTab: 1,
            page: 1,
            refuseid: "",
            refuse_content: "",
            is_self: "",
            hzshop_switch: "",
            remark: "",
            store: [],
            shopname: "",
            ghshop_id: "",
            boxType: 1,
            taday: false,
            tomorrow: false,
            show_date: false,
            minDate: "",
            maxDate: "",
            date: "",
        };
    },
    onLoad(options) {
        // 获取当前时间的1950-01-01格式字符串
        var date = new Date();
        var year = date.getFullYear();
        var month = date.getMonth() + 1;
        var day = date.getDate();
        var minDate = year + "-" + month + "-" + day;
        var maxDate = year + 1 + "-" + month + "-" + day;
        this.minDate = minDate;
        this.maxDate = maxDate;
        this.is_self = uni.getStorageSync("is_self");
        this.hzshop_switch = uni.getStorageSync("hzshop_switch");
        console.log(this.hzshop_switch, "+++++++");
        this.$u.post("api/shop/get_order_kuaidi").then((res) => {
            this.list3 = res.data;
        });
        if (options.shop_type) {
            uni.setStorageSync("shop_type", options.shop_type);
        }
        if (uni.getStorageSync("shop_type") == 2) {
            var list = [
                {
                    iconPath: "https://apishop.qiancdj.com/static/img/home.png",
                    selectedIconPath:
                        "https://apishop.qiancdj.com/img/tabber/home.png",
                    text: "商品",
                },
                {
                    iconPath:
                        "https://apishop.qiancdj.com/static/img/order.png",
                    selectedIconPath:
                        "https://apishop.qiancdj.com/img/tabber/category.png",
                    text: "订单",
                },
                {
                    iconPath: "https://apishop.qiancdj.com/static/img/mine.png",
                    selectedIconPath:
                        "https://apishop.qiancdj.com/img/tabber/user.png",
                    text: "我的",
                },
            ];
            this.tabsList = list;
            this.currentTab = 1;
            var tab = [
                {
                    name: "待支付",
                    value: 1,
                },
                {
                    name: "待发货",
                    value: 2,
                },
                {
                    name: "待收货",
                    value: 3,
                },
                {
                    name: "已取消",
                    value: 4,
                },
            ];
            this.tabList = tab;
        }
    },
    methods: {
        changeDate(e) {
            this.date = e.result;
        },
        clickDate() {
            this.show_date = true;
            this.chooseIndex = 3;
            console.log(this.chooseIndex);
        },
        choose(e) {
            this.chooseIndex = e.value;
            this.date = "";
        },
        showPop(id) {
            this.id = id;
            this.show3 = true;
        },
        showGong(id, goods_id) {
            this.id = id;
            this.show6 = true;
            this.$u
                .post("api/shop/get_goods_gh", {
                    goods_id: goods_id,
                })
                .then((res) => {
                    this.store = res.data;
                });
        },
        confirm1(e, type) {
            if (type == 1) {
                this.current = e[0].value - 1;
                this.mescroll.resetUpScroll();
            } else if (type == 2) {
                this.take = e[0].value;
                this.mescroll.resetUpScroll();
            } else if (type == 3) {
                this.code = e[0].value;
                this.corporation = e[0].label;
            } else if (type == 4) {
                console.log(e);
                this.ghshop_id = e[0].value;
                this.shopname = e[0].label;
            }
        },
        checkIdx(index, type) {
            if (type == 1) {
                this.timeIdx = index;
            } else {
                this.paymentIdx = index;
            }
            this.mescroll.resetUpScroll();
        },
        confirm() {
            let is_qczx = null;
            if (this.code !== "" && this.orderNum !== "") {
                is_qczx = 0;
            } else {
                is_qczx = 1;
            }
            if (this.boxType == 1 && (this.code == "" || this.orderNum == "")) {
                this.$u.toast("请填写快递公司和快递单号");
                return;
            } else if (this.boxType == 2) {
                if (this.date == "") {
                    if (this.chooseIndex == 3) {
                        this.$u.toast("请选择千创专线送达时间");
                        return;
                    }
                }
            }
            // return
            this.$u
                .post("/api/shop/shop_order_fh", {
                    order_id: this.id,
                    express_name: this.code, //  快递公司
                    express_no: this.orderNum, //   快递单号
                    remark: this.remark,
                    fh_type: 1,
                    is_qczx: is_qczx,
                    sdsj: this.date ? this.date : Number(this.chooseIndex) + 1,
                })
                .then((res) => {
                    this.$u.toast(res.msg);
                    if (res.code == 1) {
                        this.show3 = false;
                        this.mescroll.resetUpScroll();
                    }
                });
        },
        confirmStore() {
            this.$u
                .post("/api/shop/shop_order_fh", {
                    order_id: this.id,
                    ghshop_id: this.ghshop_id, //   快递单号
                    remark: this.remark,
                    fh_type: 2,
                })
                .then((res) => {
                    this.$u.toast(res.msg);
                    if (res.code == 1) {
                        this.show6 = false;
                        this.mescroll.resetUpScroll();
                    }
                });
        },
        upCallback(page) {
            var type = this.current + 1;
            console.log(this.current);
            if (this.current < 4) {
                var timeIdx = this.timeIdx == 0 ? "" : this.timeIdx + 1;
                var paymentIdx =
                    this.paymentIdx == 0 ? "" : this.paymentIdx + 1;
                this.mescroll.optUp.textNoMore = "-已经到底啦-";
                this.$u
                    .post("/api/shop/shop_order_noun", {
                        page: page.num,
                        // limit: page.size,
                        type: type,
                        create: timeIdx,
                        pay: paymentIdx,
                        take: this.take,
                        keyword: this.keyword,
                    })
                    .then((res) => {
                        this.mescroll.endBySize(
                            res.data.data.length,
                            res.data.total
                        );
                        if (page.num == 1) this.flowList = []; //如果是第一页需手动制空列表
                        this.flowList = this.flowList.concat(res.data.data); //追加新数据
                    })
                    .catch(() => {
                        //联网失败, 结束加载
                        this.mescroll.endErr();
                    });
            } else {
                this.change(this.current);
            }
        },
        change(index) {
            this.current = index;
            var timeIdx = this.timeIdx == 0 ? "" : this.timeIdx + 1;
            var paymentIdx = this.paymentIdx == 0 ? "" : this.paymentIdx + 1;
            this.mescroll.optUp.textNoMore = "-已经到底啦-";
            if (this.current == 4) {
                var state = "";
                this.$u
                    .post("/api/refund/index", {
                        page: this.page,
                        create: timeIdx,
                        pay: paymentIdx,
                        take: this.take,
                        keyword: this.keyword,
                        state: state,
                    })
                    .then((res) => {
                        this.mescroll.endBySize(
                            res.data.data.length,
                            res.data.total
                        );
                        if (this.page == 1) this.flowList = []; //如果是第一页需手动制空列表
                        this.flowList = this.flowList.concat(res.data.data); //追加新数据
                    });
                return false;
            } else if (this.current == 5) {
                var state = 0;
                this.$u
                    .post("/api/refund/index", {
                        page: this.page,
                        create: timeIdx,
                        pay: paymentIdx,
                        take: this.take,
                        keyword: this.keyword,
                        state: state,
                    })
                    .then((res) => {
                        this.mescroll.endBySize(
                            res.data.data.length,
                            res.data.total
                        );
                        if (this.page == 1) this.flowList = []; //如果是第一页需手动制空列表
                        this.flowList = this.flowList.concat(res.data.data); //追加新数据
                    });
                return false;
            } else if (this.current == 6) {
                var state = 4;
                this.$u
                    .post("/api/refund/index", {
                        page: this.page,
                        create: timeIdx,
                        pay: paymentIdx,
                        take: this.take,
                        keyword: this.keyword,
                        state: state,
                    })
                    .then((res) => {
                        this.mescroll.endBySize(
                            res.data.data.length,
                            res.data.total
                        );
                        if (this.page == 1) this.flowList = []; //如果是第一页需手动制空列表
                        this.flowList = this.flowList.concat(res.data.data); //追加新数据
                    });
                return false;
            } else if (this.current == 7) {
                var state = 2;
                this.$u
                    .post("/api/refund/index", {
                        page: this.page,
                        create: timeIdx,
                        pay: paymentIdx,
                        take: this.take,
                        keyword: this.keyword,
                        state: state,
                    })
                    .then((res) => {
                        this.mescroll.endBySize(
                            res.data.data.length,
                            res.data.total
                        );
                        if (this.page == 1) this.flowList = []; //如果是第一页需手动制空列表
                        this.flowList = this.flowList.concat(res.data.data); //追加新数据
                    });
                return false;
            }
            this.mescroll.resetUpScroll();
        },
        changeTab(e) {
            if (uni.getStorageSync("shop_type") == 1) {
                if (e == 0) {
                    this.$func.jump("/yCreate/pages/goodsManagement");
                } else if (e == 2) {
                    this.$func.jump("/yCreate/pages/reviewOrder");
                } else if (e == 3) {
                    this.$func.jump("/wNew/pages/freight");
                } else if (e == 4) {
                    this.$func.jump("/wNew/subPages/technician/tabBar/mine");
                }
            } else if (uni.getStorageSync("shop_type") == 2) {
                if (e == 0) {
                    this.$func.jump("/yCreate/pages/goodsManagement");
                } else if (e == 2) {
                    this.$func.jump("/wNew/subPages/technician/tabBar/mine");
                }
            }
        },
        getlist() {
            var type = this.current + 1;
            var timeIdx = this.timeIdx == 0 ? "" : this.timeIdx + 1;
            var paymentIdx = this.paymentIdx == 0 ? "" : this.paymentIdx + 1;
            this.$u
                .post("/api/shop/shop_order_noun", {
                    page: 1,
                    // limit: page.size,
                    type: type,
                    create: timeIdx,
                    pay: paymentIdx,
                    take: this.take,
                    keyword: this.keyword,
                })
                .then((res) => {
                    this.mescroll.endBySize(
                        res.data.data.length,
                        res.data.total
                    );
                    this.flowList = []; //如果是第一页需手动制空列表
                    this.flowList = this.flowList.concat(res.data.data); //追加新数据
                });
            this.show_screen = false;
        },
        goDetail(id) {
            if (this.current < 4) {
                uni.navigateTo({
                    url:
                        "/yCreate/pages/orderDetail?id=" +
                        id +
                        "&shop=shop" +
                        "&showPayType=0",
                });
            } else if (this.current > 3) {
                uni.navigateTo({
                    url: "/yCreate/pages/refunddetail?id=" + id,
                });
            }
        },
        //同意退款
        agree(id) {
            this.$u
                .post("/api/refund/agree", {
                    ids: id,
                })
                .then((res) => {
                    this.change(4);
                    if (res.code == 0) {
                        this.$util.showToast({
                            title: res.msg,
                        });
                    }
                });
        },
        //拒绝退款
        refuse(id) {
            this.refuseid = id;
            this.show5 = true;
        },
        //退款
        getTui() {
            this.$u
                .post("/api/refund/refuse", {
                    ids: this.refuseid,
                    refuse_content: this.refuse_content,
                })
                .then((res) => {
                    this.show5 = false;
                    this.change(4);
                });
        },
        //确认收货
        rece(id) {
            this.$u
                .post("/api/refun/receiving", {
                    ids: id,
                })
                .then((res) => {
                    this.change(4);
                });
        },
    },
};
</script>

<style lang="scss" scoped>
@import url(@/components/common.css);

page {
    background-color: #f6f6f6;
}

.tabs {
    position: sticky;
    top: 0;
    z-index: 999;
    background-color: #fff;
    padding: 30rpx 20rpx;

    .screen {
        width: 40rpx;
        height: auto;
    }
}

.all {
    padding: 0 24rpx;

    .card {
        width: 100%;
        margin-top: 18rpx;
        padding: 30rpx 20rpx;
        background: #ffffff;
        border-radius: 10rpx;

        .shop-message {
            font-size: 32rpx;

            image {
                width: 28rpx;
                height: auto;
                margin-right: 10rpx;
            }
        }

        .top {
            // margin: 30rpx 0;
            margin-bottom: 30rpx;
            font-size: 24rpx;

            .state {
                color: #888;
            }
        }

        .head-img {
            width: 160rpx;
            height: 160rpx;
            border-radius: 10rpx;
            margin-right: 20rpx;
            flex-shrink: 0;
        }

        .cont {
            width: 100%;

            .name {
                margin-bottom: 22rpx;
                font-size: 28rpx;
            }

            .content {
                font-size: 24rpx;
                color: #888888;
            }

            .bot {
                margin-top: 40rpx;
                font-size: 26rpx;
                color: #888;

                .price {
                    font-family: PingFang SC;
                    font-weight: 500;
                    color: #da0000;
                }

                text {
                    font-size: 32rpx;
                }
            }

            .price {
                font-size: 40rpx !important;
                font-weight: 550;
                color: #ef5205;

                text {
                    font-weight: 500;
                    font-size: 20rpx;
                }
            }

            .number {
                font-size: 28rpx;
                font-weight: bold;
                color: #222222;
            }
        }
    }
}

.time {
    font-size: 24rpx;
    color: #888888;
}

.button {
    margin-left: 20rpx;
    display: flex;
    align-items: center;
    justify-content: center;
    // width: 140rpx;
    padding: 0 25rpx;
    height: 52rpx;
    background: linear-gradient(98deg, #5d64ca 0%, #6f9bdf 100%);
    border-radius: 40rpx;
    font-size: 24rpx;
    color: #ffffff;
}

.button1 {
    border: 1rpx solid #888888;
    background: #fff;
    color: #888888;
}

.pop {
    .box-item {
        width: 200rpx;
        height: 52rpx;
        background: #f6f6f6;
        border-radius: 40rpx;
        font-size: 24rpx;

        image {
            margin-left: 10rpx;
            width: 20rpx;
            height: auto;
        }
    }

    .options-item {
        padding: 30rpx 0 0 0;

        .title {
            margin-bottom: 20rpx;
            font-size: 28rpx;
            font-weight: bold;
        }

        .options-box {
            margin: 0 30rpx 30rpx 0;
            width: 180rpx;
            height: 52rpx;
            background: #f5f5f5;
            color: #888888;
            border-radius: 40rpx;
            font-size: 24rpx;
        }

        .select-box {
            background: linear-gradient(98deg, #5d64ca 0%, #6f9bdf 100%);
            color: #ffffff;
        }
    }

    .btn {
        width: 50%;
        height: 100rpx;
        background: #f6f6f6;
        font-size: 28rpx;
        font-weight: bold;
    }

    .btn2 {
        background: #606dce;
        color: #ffffff;
    }
}

.card2 {
    width: 600rpx;
    padding: 0 40rpx 20rpx 40rpx;

    .pop-tit {
        color: #606dce;
        text-align: center;
        margin-top: 30rpx;
        font-size: 35rpx;
        font-weight: 550;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .item {
        padding: 40rpx 0;
        font-size: 30rpx;

        input {
            font-size: 30rpx;
            text-align: right;
        }

        .ipt-sty,
        .right {
            font-size: 30rpx;
            color: #b0b0b0;
        }

        .right2 {
            color: #333;
        }
    }

    .pop-button {
        margin-top: 40rpx;

        view {
            width: 48%;
            height: 80rpx;
            border-radius: 40rpx;
            border: 1rpx solid #888;
            color: #888;
        }

        .b2 {
            background-color: #606dce;
            border: none;
            color: #fff;
        }
    }
}

.tabsbg {
    overflow-x: scroll;
    white-space: nowrap;
    display: flex;
    flex-wrap: nowrap;
}

.tabline {
    width: 45rpx;
    height: 6rpx;
    border-radius: 30rpx;
    background: #606dce;
    margin-top: 10rpx;
}
/deep/.uni-label-pointer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
}
/deep/.uni-picker-container {
    z-index: 999999 !important;
}
/deep/.u-tabbar__content {
    z-index: 999 !important;
}
.inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
}
.borderBottomLine {
    border-bottom: 3px solid #606dce;
    width: 30px;
    margin: 5px 0 0 0;
}
.bottomLine {
    margin: 5px 0 0 0;
    border-bottom: 3px solid rgba(0, 0, 0, 0);
    width: 30px;
}
</style>